package com.hfmall.mapper;

import com.hfmall.entity.HfOrder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hfmall.entity.HfUser;
import com.hfmall.entity.PageBean;
import com.hfmall.provider.OrderProvider;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author liclo
 * @since 2021-08-12
 */
public interface HfOrderMapper extends BaseMapper<HfOrder> {

    int getAll(int userId);

    int getCountByStatus(@Param("userId") int userId, @Param("status") String status);

    List<HfOrder> list(@Param("order") HfOrder order);

    HfOrder getOne(int id);
    @SelectProvider(type = OrderProvider.class,method = "select")
    @Results({
            @Result(id = true,column = "id",property = "id"),
            @Result(property = "createDate",column = "create_date"),
            @Result(property = "orderNo",column = "order_no"),
            @Result(property = "name",column = "name"),
            @Result(property = "address",column = "address"),
            @Result(property = "payMoney",column = "paymoney"),
            @Result(property = "status",column = "status")
    })
    List<HfOrder>getByCondition(HfOrder order);
    @Update("UPDATE hf_order SET status=#{status} WHERE id=#{id}")
    void updateByID(HfOrder order);
    @Select("select * from hf_order where create_date>=#{startTime} and create_date<=#{endTime}")
    List<HfOrder> selectByTime(@Param("startTime") String startTime,@Param("endTime")String endTime);
    @Select("select * from hf_order  WHERE status=#{status}")
    List<HfOrder> selectByStatus(int status);
    @Select("id,order_no,address,create_date,user_id,name,phone,pay_time,send_time,status,get_time,paymoney,isdel FROM hf_order")
    PageBean<HfOrder> getB(int currPage, HfOrder order);
}
